using System;
using SqlQueryBuilder.Util;

namespace SqlQueryBuilder
{
    /// <summary>
    /// Class that allow to format a DateTime to Sql date
    /// </summary>
    public class SqlDateTime
    {
        private DateTime Date;
        private readonly CultureDate Language;

        /// <summary>
        /// Initializes a new instance of the <see cref="SqlDateTime"/> class.
        /// </summary>
        /// <param name="date">The date.</param>
        /// <param name="language">The language.</param>
        public SqlDateTime(DateTime date, CultureDateType language)
        {
            Date = date;
            Language = new CultureDate(language);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="SqlDateTime"/> class.
        /// </summary>
        /// <param name="date">The date.</param>
        public SqlDateTime(DateTime date) : this(date, CultureDateType.ODBC) {}

        /// <summary>
        /// Gets the date.
        /// </summary>
        /// <returns></returns>
        public string getDate()
        {
            return string.Format("'{0}'",Date.ToString(Language.GetTemplate()));
        }
    }
}